package thread;

import java.util.Scanner;

public class Demo24 {
    public static void main(String[] args) {

        Object lock = new Object();

        Thread t1 = new Thread(()->{
            System.out.println("wait 前");
            synchronized (lock) {
                try {
                    lock.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("wait 后");
            }
        });

        Thread t2 = new Thread(()->{
            Scanner scanner = new Scanner(System.in);
            System.out.println("通知唤醒t1");

            scanner.next();//带有阻塞的操作，等待用户控制台输入

            synchronized (lock) {
                lock.notify();
            }
        });

        t1.start();
        t2.start();

    }
}
